home *** CD-ROM | disk | FTP | other *** search
- /*
- * Resident segment for INTERNAT
- *
- * William S. Hall
- * 3665 Benton Street, #66
- * Santa Clara, CA 95051
- *
- */
-
- #define NOKANJI
- #define NOCOMM
- #define NOSOUND
- #include <windows.h>
- #include <string.h>
- #include "internat.h"
- #include "interint.h"
- #include "interfns.h"
- #include "interstr.h"
- #include "intrlang.h"
-
- /* local functions */
- static void NEAR MainWndPaint(HWND hWnd, HDC hDC);
- static void NEAR LangDlgInit(HWND hDlg);
- static int NEAR LangDlgGet(HWND hDlg);
-
- /* Entry point for program */
- int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
- LPSTR lpszCmdLine, int cmdShow)
- {
-
- MSG msg;
-
- /* If initialization is not successful then exit */
- if (!InitProgram(hInstance,hPrevInstance, lpszCmdLine, cmdShow))
- return FALSE;
-
- /* Retrieve messages from Windows */
- while (GetMessage((LPMSG)&msg,NULL,0,0)) {
- TranslateMessage((LPMSG)&msg);
- DispatchMessage((LPMSG)&msg);
- }
- return msg.wParam; /* exit program */
- }
-
- /* All messages are processed here */
- long FAR PASCAL MainWndProc(HWND hWnd,unsigned message,WORD wParam,LONG lParam)
- {
-
- PAINTSTRUCT ps;
-
- switch(message) {
-
- case WM_KEYDOWN: /* show the keyboard parameters */
- case WM_KEYUP:
- case WM_CHAR:
- case WM_DEADCHAR:
- DoKeyStuff(hWnd, message, wParam, lParam);
- break;
-
- case WM_CREATE:
- WndCreate(hWnd);
- break;
-
- case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
-
- case WM_COMMAND:
- WndCommand(hWnd, wParam);
- break;
-
- case WM_DESTROY: /* free the language resource, if used */
- if ((hRC) && (hRC != hInst))
- FreeLibrary(hRC);
- PostQuitMessage(0);
- break;
-
- case WM_PAINT:
- BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);
- MainWndPaint(hWnd, ps.hdc);
- EndPaint(hWnd, (LPPAINTSTRUCT)&ps);
- break;
-
- default:
- return ((long)DefWindowProc(hWnd,message,wParam,lParam));
- break;
- }
- return(0L);
- }
-
- /* update the window */
- static void NEAR MainWndPaint(HWND hWnd, HDC hDC)
- {
-
- #define SHSP 8192
-
- register int i, j;
- int base;
- int buf[16];
- int x, y;
-
- /* Select colors and character set */
- SetBkColor(hDC, GetSysColor(COLOR_WINDOW));
- SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
- SelectObject(hDC, OEMCharSet ? GetStockObject(OEM_FIXED_FONT) :
- GetStockObject(SYSTEM_FIXED_FONT));
-
- /* Draw the character display according to the buffer contents */
- y = cheight;
- x = cwidth;
- for (i = 0; i < 16; i++) {
- base = 16 * i;
- for (j = 0; j < 16; j++) {
- buf[j] = display[base + j] + SHSP;
- }
- TextOut(hDC, x, y, (BYTE *)buf, sizeof(buf));
- y += cheight;
- }
-
- /* Show the action of the keys */
- SelectObject(hDC, GetStockObject(SYSTEM_FIXED_FONT));
- x = kwidth;
- y = cheight;
-
- TextOut(hDC, x, y, kbdbuf, strlen(kbdbuf));
- y += cheight;
- TextOut(hDC, x, y, kbubuf, strlen(kbubuf));
- y += cheight;
- TextOut(hDC, x, y, kbbuf, strlen(kbbuf));
- }
-
- /* manage ego box */
- BOOL FAR PASCAL AboutDlg(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
- {
-
- switch(message) {
-
- case WM_INITDIALOG:
- break;
-
- case WM_COMMAND:
- switch(wParam) {
- case IDOK:
- case IDCANCEL:
- EndDialog(hDlg, TRUE);
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /* Manage a request to change the language */
- BOOL FAR PASCAL LangDlgFunc(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
- {
-
- switch(message) {
-
- case WM_INITDIALOG:
- LangDlgInit(hDlg);
- break;
-
- case WM_COMMAND:
- switch(wParam) {
- case IDOK:
- EndDialog(hDlg, LangDlgGet(hDlg));
- break;
-
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
- return TRUE;
- }
-
- /* Initialize the language selection box */
- static void NEAR LangDlgInit(HWND hDlg)
- {
- char buf[80];
- register int i;
-
- for (i = IDS_ENGLISH; i <= IDS_PIGLATIN; i++) {
- LoadString(hInst, i, buf, sizeof(buf));
- SendDlgItemMessage(hDlg,IDD_LANGLIST,CB_ADDSTRING,0,(LONG)(LPSTR)buf);
- }
- SendDlgItemMessage(hDlg, IDD_LANGLIST, CB_SETCURSEL, 0, 0L);
-
- }
-
- /* Get the selected langauge */
- static int NEAR LangDlgGet(HWND hDlg)
- {
- char buf[80];
- char name[80];
- int sel;
- int i = IDS_ENGLISH;
-
- sel = (int)SendDlgItemMessage(hDlg, IDD_LANGLIST, CB_GETCURSEL, 0, 0L);
- if (sel != CB_ERR) {
- SendDlgItemMessage(hDlg,IDD_LANGLIST,CB_GETLBTEXT,sel,(LONG)(LPSTR)name);
- for (i = IDS_ENGLISH; i <= IDS_PIGLATIN; i++) {
- LoadString(hInst, i, buf, sizeof(buf));
- if (lstrcmp(buf, name) == 0)
- break;
- }
- }
- return i;
- }
-